package org.beetl.sql.clazz;

import java.util.ArrayList;
import java.util.List;

import org.beetl.sql.clazz.ClassAnnotation;
import org.beetl.sql.core.kit.StringKit;

public abstract class LegacyNameConversion extends org.beetl.sql.clazz.NameConversion{
	/***
	 * 根据class获取表中所有的id
	 * 
	 * @return
	 */
	public List<String> getId() {
		List<String> list = new ArrayList<String>();
		list.add("id");
		return list;
	}

	protected String getAnnotationColName(Class c, String attrName) {
//		String col = super.getAnnotationColName(c, attrName);
		String col = null;
		if(StringKit.isBlank(col)) {
			ClassAnnotation classAnnotation = LegacyClassAnnotation.getClassAnnotation(c);
			col = classAnnotation.getAttrAnnotationName().get(attrName);			
		}
		return col;
	}

	protected String getAnnotationAttrName(Class c, String colName) {
//		String attr = super.getAnnotationAttrName(c, colName);
		String attr = null;
		if(StringKit.isBlank(attr)) {
			ClassAnnotation classAnnotation = LegacyClassAnnotation.getClassAnnotation(c);
			attr = (String) classAnnotation.getColAnnotationName().get(colName);			
		}
		return attr;
	}
	
	@Override
	protected String getAnnotationTableName(Class clazz) {
//		String tname = super.getAnnotationTableName(clazz);
		String tname = null;
		if(StringKit.isBlank(tname)) {
			ClassAnnotation classAnnotation = LegacyClassAnnotation.getClassAnnotation(clazz);
			tname = classAnnotation.getTableName();
		}
		return tname;
	}
}
